<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Sidebar Animation with GSAP</title>
    <style>
        body {
            margin: 0;
            font-family: Arial, sans-serif;
            display: flex;
            flex-direction: column;
            height: 100vh;
        }

        .header {
            background-color: #333;
            color: white;
            padding: 1rem;
            text-align: center;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .header .left-button {
            margin-left: 1rem;
        }

        .header .right-button {
            margin-right: 1rem;
        }

        .container {
            display: flex;
            flex: 1;
            overflow: hidden;
        }

        .sidebar {
            background-color: #444;
            color: white;
            width: 250px;

            box-sizing: border-box;
        }

        .content {
            flex: 1;
            padding: 1rem;
            background-color: #f4f4f4;
            transition: all 0.3s ease;
        }

        button {
            padding: 0.5rem 1rem;
            background-color: #007BFF;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }

        button:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
<div class="header">
    <button class="left-button">Left Button</button>
    <span>Header</span>
    <button class="right-button" id="toggleSidebar">Toggle Sidebar</button>
</div>
<div class="container">
    <div class="sidebar" id="sidebar">

    </div>
    <div class="content" id="content">
        <p>Main Content Area</p>
    </div>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<script>
    const sidebar = document.getElementById('sidebar');
    const content = document.getElementById('content');
    const toggleButton = document.getElementById('toggleSidebar');

    let isSidebarVisible = true;

    toggleButton.addEventListener('click', () => {
        if (isSidebarVisible) {
            gsap.to(sidebar, {duration: 0.3, width: 0, ease: 'power2.inOut'});
        } else {
            gsap.to(sidebar, {duration: 0.3, width: 250, ease: 'power2.inOut'});
        }
        isSidebarVisible = !isSidebarVisible;
    });
</script>
</body>
</html>
